#!/bin/bash
#docker stack rm lm-admin-stack
if ${build} ; then
  Harbor_Addr=192.168.10.29:5000
  SERVER_ARR=("ruoyi-auth" "ruoyi-system" "ruoyi-gateway")
  docker login $Harbor_Addr -u admin -p root12345 # 发送到harbor服务器

  for server_name in ${SERVER_ARR[@]}
  do
    cd $server_name
    REP=$Harbor_Addr/lemon-admin/$server_name:${tag}           # 镜像存储地址
    docker build -f Dockerfile -t $REP . --no-cache   # 利用dockerfile构建镜像
    docker push $REP
    docker rmi $REP
    cd ..
  done
  docker logout $Harbor_Addr
fi
#docker stack deploy -c docker-stack.yml lm-admin-stack
docker stack deploy --prune --detach=true --with-registry-auth -c docker-stack.yml lm-admin-stack

